package cn.pku.edu.cs.ldn;

import cn.pku.edu.cs.ldn.util.TestUtil;
import cn.pku.edu.cs.ldn.view.WebImageView;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;

public class TestWebImageViewActivity extends Activity {

	private ListView listView = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test_web_imageview);
		listView = (ListView) findViewById(R.id.listView);
		listView.setAdapter(new SimpleAdapter());

		Uri uri = Uri.parse("www.baidu.com");
		Log.i("", "onCreate: " + uri.getScheme());
		Log.i("", "onCreate: " + uri.isAbsolute());
		Log.i("", "onCreate: " + uri.isHierarchical());
		Log.i("", "onCreate: " + uri.isOpaque());
		Log.i("", "onCreate: " + uri.isRelative());
	}

	class SimpleAdapter extends BaseAdapter {

		LayoutInflater inflater = null;

		public SimpleAdapter() {
			inflater = LayoutInflater.from(TestWebImageViewActivity.this);
		}

		@Override
		public int getCount() {
			return TestUtil.imageUrls.length;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			Log.v("", "getView: " + position);
			if (convertView == null) {
				convertView = inflater.inflate(R.layout.item_listview, null);
			}
			WebImageView webImageView = (WebImageView) convertView
					.findViewById(R.id.webImageView);
			webImageView.setImageUrl(TestUtil.imageUrls[position]);
			return convertView;
		}
	}
}
